<!--
  停车场区域表添加页面
  User: YanZengBao
  Date: 2020-02-19
-->
<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org">

<!-- BEGIN FORM-->
<div class="portlet light">
    <div class="portlet-title">
        <div class="caption">
            <span class="caption-subject font-red-sunglo bold uppercase">停车场区域表添加</span>
            <span class="caption-helper">添加一条停车场区域表数据</span>
        </div>
    </div>
    <div class="portlet-body form">
        <!-- BEGIN FORM-->
        <form action="#" class="form-horizontal" id="save-module">
            <div class="form-body">

                <!--  字段信息-->
                <!-- 停车场ID 字段信息-->
                <div class="form-group hide">
                    <label class="col-md-3 control-label">停车场名称</label>
                    <div class="col-md-7">
                        <div class="input-inline ">
                            <div class="input-group">
                                        <span class="input-group-addon">
                                            <i class="fa fa-edit"></i>
                                        </span>
                                <input type="text" class="form-control" id="parkName" required name="parkName"
                                       placeholder="停车场名称">
                            </div>
                        </div>
                    </div>
                </div>
                <!-- 停车场名称 字段信息-->
                <div class="form-group">
                    <label class="col-md-3 control-label">停车场名称</label>
                    <div class="col-md-7">
                        <div class="input-inline ">
                            <div class="input-group">
                                        <span class="input-group-addon">
                                            <i class="fa fa-edit"></i>
                                        </span>
                                <select class="form-control" id="parkId" required name="parkId" onchange="choosePark()">
                                    <option value="">请选择停车场</option>
                                    <option th:each="data,iterStat : ${parkList}" th:value="${data.id}"
                                            th:text="${data.name}"></option>
                                </select>
                                <!-- <input type="text" class="form-control" required name="parkName" placeholder="停车场名称">-->
                            </div>
                        </div>
                    </div>
                </div>
                <!-- 区域名称 字段信息-->
                <div class="form-group">
                    <label class="col-md-3 control-label">区域名称</label>
                    <div class="col-md-7">
                        <div class="input-inline ">
                            <div class="input-group">
                                        <span class="input-group-addon">
                                            <i class="fa fa-edit"></i>
                                        </span>
                                <input type="text" class="form-control" maxlength="100" required name="name" placeholder="区域名称">
                            </div>
                        </div>
                    </div>
                </div>
                <!-- 区域编号 字段信息-->
                <div class="form-group">
                    <label class="col-md-3 control-label">区域编号</label>
                    <div class="col-md-7">
                        <div class="input-inline ">
                            <div class="input-group">
                                        <span class="input-group-addon">
                                            <i class="fa fa-edit"></i>
                                        </span>
                                <input type="text" class="form-control" maxlength="50" required name="number" placeholder="区域编号">
                            </div>
                        </div>
                    </div>
                </div>

                <!-- 预留字段（区域类型） 字段信息-->
                <!--           <div class="form-group">
                               <label class="col-md-3 control-label">预留字段(区域类型)</label>
                               <div class="col-md-7">
                                   <div class="input-inline ">
                                       <div class="input-group">
                                           <span class="input-group-addon">
                                               <i class="fa fa-edit"></i>
                                           </span>
                                           <input type="number" class="form-control" required digits="true" name="areaType" placeholder="预留字段">
                                       </div>
                                   </div>
                               </div>
                           </div>-->


            </div>
            <div class="form-actions">
                <div class="row">
                    <div class="col-md-12">
                        <div class="row">
                            <div class="col-md-offset-3 col-md-7">
                                <button type="button" class="btn green" onclick="save();">保存</button>
                                <button type="button" class="btn default" onclick="layer.close(layer_addModule);">取消
                                </button>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </form>
        <!-- END FORM-->
    </div>
</div>

<script>

    $(function () {
        //初始化页面
        initPage();
    });

    //选择停车场，保存停车场名称
    function choosePark() {
        let parkName = $("#parkId option:selected").text();
        $("#parkName").val(parkName);
    }

    function save() {
        let param = tools.formParams("save-module");
        if (tools.valid("save-module")) {
            tools.post("/parkArea/save", param, function (data) {
                if (data.success) {
                    layer.msg(data.message, {icon: 1, time: 2000}, function () {
                        //刷新列表页面
                        toPage(null);
                        //关闭弹窗
                        layer.close(layer_addModule);
                    });
                } else {
                    tools.errorTip(data.code,data.message);
                }
            });
        }
    }

</script>
</html>